﻿<!DOCTYPE HTML>
<html>
<head>
    <span id="get_count"></span>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>{$Think.config.site.title}</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.keywords}">
    <link rel="Bookmark" href="__ROOT__/favicon.ico" >
    <link rel="Shortcut Icon" href="__ROOT__/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__LIB__/html5.js"></script>
    <script type="text/javascript" src="__LIB__/respond.min.js"></script>
    <script type="text/javascript" src="__LIB__/PIE_IE678.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__STATIC__/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__LIB__/Hui-iconfont/1.0.7/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__LIB__/icheck/icheck.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/app.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="__LIB__/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    {include file='template/javascript_vars' /}
</head>
<body>
<header class="navbar-wrapper">
    <div class="navbar navbar-fixed-top">
        <div class="container-fluid cl"> <a class="logo navbar-logo f-l mr-10 hidden-xs" href="{:\\think\\Url::build('/admin')}">{$Think.config.site.name}</a> <a class="logo navbar-logo-m f-l mr-10 visible-xs" href="{:\\think\\Url::build('/admin')}">tp</a> <span class="logo navbar-slogan f-l mr-10 hidden-xs">{$Think.config.site.version}</span> <a aria-hidden="false" class="nav-toggle Hui-iconfont visible-xs" href="javascript:">&#xe667;</a>
            <!--{include file='template/nav_left' /}-->
            <nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
                <ul class="cl">
                    <li>{$Think.session.realname}</li>
                    <li class="dropDown dropDown_hover"> <a href="#" class="dropDown_A">{$Think.session.real_name} <i class="Hui-iconfont">&#xe6d5;</i></a>
                        <ul class="dropDown-menu menu radius box-shadow">
                            <li><a href="javascript:" onclick="layer_open('个人信息', '{:\\think\\Url::build(\'Pub/profile\')}')">个人信息</a></li>
                            <li><a href="javascript:" onclick="layer_open('个人信息', '{:\\think\\Url::build(\'Pub/password\')}')">修改密码</a></li>
                            <li><a href="javascript:" onclick="logout()">退出</a></li>
                        </ul>
                    </li>
                    <!--<li id="Hui-msg"> <a href="javascript:" onclick="layer_open('重新分配','/admin/dispatch_traveler_group/in_again.html')" title="需要重新分配"><span class="badge badge-danger" id="suspendOrder"><?php use think\Db;?>{php}echo Db::name('dispatch_traveler_group')->where('dispatch_group_status','proceed')->where('is_suspend','2')->count();{/php}</span><i class="Hui-iconfont" style="font-size:18px">&#xe68a;</i></a> </li>-->
                    <li id="Hui-msg"> <a href="javascript:" onclick="layer_open('系统通知','/admin/system_notification/index.html')" title="系统通知">
                        <span class="badge badge-danger" id="systemNotification">
                            {php}
                                if(UID == 1){
                                    $role_id = 0;
                                }else{
                                    $role_id = Db::name('admin_role_user')
                                        ->where('user_id',UID)
                                        ->value('role_id');
                                }
                                $list_1 = Db::name('system_notification')
                                    ->where('from_account',UID)
                                    ->where('is_from',1)
                                    ->where('status','unfinished')
                                    ->field('id')
                                    ->order('id desc')
                                    ->select();

                                $list_2 = Db::name('system_notification')
                                    ->where('send_department',$role_id)
                                    ->where('is_from',0)
                                    ->where('status','unfinished')
                                    ->field('id')
                                    ->order('id desc')
                                    ->select();
                                $list = array_merge($list_1,$list_2);
                                $num = count($list);
                                echo $num;
                            {/php}
                            <input id="systemNotification_val" type="hidden" value="{$num}">
                        </span>
                        <i class="Hui-iconfont" style="font-size:18px">&#xe622;</i>
                    </a>
                    </li>
                    <li id="Hui-msg"> <a href="javascript:" onclick="open_window('重新分配司机','/admin/dispatch_traveler_group/in_again.html')" title="需要重新分配"><span class="badge badge-danger" id="driverRefuse">
                        {php}
                             $map['dtg.dispatch_group_status'] = 'undistributed';
                             $list = DB('dispatch_traveler_group')
                                ->alias('dtg')
                                ->join('tp_dispatch_order dor', 'dor.dispatch_id=dtg.dispatch_id', 'left')
                                ->join('tp_order or', 'or.id=dor.oid', 'left')
                                ->join('tp_driver dr', 'dr.user_id=dtg.driver_user_id', 'left')
                                ->field('dtg.id')
                                ->where($map)
                                ->order("dtg.id desc")
                                ->group("dor.dispatch_id")
                                ->select();
                             echo count($list);
                        {/php}
                    </span><i class="Hui-iconfont" style="font-size:18px">&#xe669;</i></a> </li>
                    <li id="Hui-msg"> <a href="javascript:" onclick="open_window('请假管理','/admin/leave/index.html')" title="请假管理"><span class="badge badge-danger" id="leaveManage">{php}echo Db::name('leave')->where('leave_status','apply')->count();{/php}</span><i class="Hui-iconfont" style="font-size:18px">&#xe667;</i></a> </li>
                    <li id="Hui-skin" class="dropDown right dropDown_hover"> <a href="javascript:" class="dropDown_A" title="换肤"><i class="Hui-iconfont" style="font-size:18px">&#xe62a;</i></a>
                        <ul class="dropDown-menu menu radius box-shadow">
                            <li><a href="javascript:" data-val="default" title="默认（黑色）">默认（黑色）</a></li>
                            <li><a href="javascript:" data-val="blue" title="蓝色">蓝色</a></li>
                            <li><a href="javascript:" data-val="green" title="绿色">绿色</a></li>
                            <li><a href="javascript:" data-val="red" title="红色">红色</a></li>
                            <li><a href="javascript:" data-val="yellow" title="黄色">黄色</a></li>
                            <li><a href="javascript:" data-val="orange" title="绿色">橙色</a></li>
                        </ul>
                    </li>
                </ul>
            </nav>
        </div>
<!--        <audio id="myaudio" src="/static/admin/1.mp3" controls loop="false" hidden="true"></audio>-->
    </div>
</header>
<aside class="Hui-aside">
    <input runat="server" id="divScrollValue" type="hidden" value="" />
    <div class="menu_dropdown bk_2">
        {include file='template/nav_menu' /}
    </div>
</aside>
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:" onClick="displaynavbar(this)"></a></div>
<section class="Hui-article-box">
    <div id="Hui-tabNav" class="Hui-tabNav hidden-xs">
        <div class="Hui-tabNav-wp">
            <ul id="min_title_list" class="acrossTab cl">
                <li class="active"><span title="我的桌面" data-href="welcome.html">我的桌面</span><em></em></li>
            </ul>
        </div>
        <div class="Hui-tabNav-more btn-group"><a id="js-tabNav-prev" class="btn radius btn-default size-S" href="javascript:;"><i class="Hui-iconfont">&#xe6d4;</i></a><a id="js-tabNav-next" class="btn radius btn-default size-S" href="javascript:"><i class="Hui-iconfont">&#xe6d7;</i></a></div>
    </div>
    <div id="iframe_box" class="Hui-article">
        <div class="show_iframe">
            <div style="display:none" class="loading"></div>
            <iframe scrolling="yes" frameborder="0" src="{:\\think\\Url::build('welcome')}"></iframe>
        </div>
    </div>
</section>
<script type="text/javascript" src="__LIB__/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__LIB__/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__STATIC__/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="__STATIC__/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="__STATIC__/js/app.js"></script>
<script>
    function logout() {
        layer.confirm('您确定要退出登录？',{title:'登出提醒'},function (index) {
            location.href = '{:\\think\\Url::build("Pub/logout")}'
        })
    }
</script>
<script>
    var int = setInterval(getCount,600000); //10分钟执行一次
    var int2 = setInterval(sysNotifi,600000); //10分钟执行一次
    var int3 = setInterval(getMessage,6000);
    function sysNotifi() {
        $.ajax({
            url: '/admin/system_notification/sys_notifi',
            type: 'get',
            success: function (res) {
                if(res.code == 0){
                    layer.msg(res.msg,{
                        time: 2500,
                    });
                }
            }
        });
    }
    function getMessage() {
        var num = $("#systemNotification_val").val()
        var time=new Date().getTime();
        console.log('num',num);
        $.ajax({
            url: '/admin/system_notification/get_message',
            type: 'get',
            data:{num:num,time:time},
            success: function (res) {
                if(res.code == 0){
                    layer.msg(res.msg,{
                        time: 4000,
                    });
                    console.log('systemNotification11',$("#systemNotification"))
                    $("#systemNotification").html(res.data);
                    console.log('systemNotification',$("#systemNotification"))
                    console.log(' res.data', res.data)
                }
            }
        });
    }
    function getCount() {
        var userId = '{$Think.session.auth_id}';
        var userName = '{$Think.session.real_name}';
        $.ajax({
            url: '/admin/Index/test',
            type: 'get',
            data: {'userId':userId,'user_name':userName},
            success: function (res) {
                console.log(res)
                //更新图标数字
                if (res.data.val == 3){
                    var driverRefuseCount = 0;
                    if (res.data.driverRefuseCount) {
                        driverRefuseCount = res.data.driverRefuseCount
                    }
                    var suspendOrderCount = 0;
                    if (res.data.suspendOrderCount) {
                        suspendOrderCount = res.data.suspendOrderCount
                    }
                    var leaveManageCount = 0;
                    if (res.data.leaveManageCount) {
                        leaveManageCount = res.data.leaveManageCount
                    }
                    $('#driverRefuse').html(driverRefuseCount)
                    $('#suspendOrder').html(suspendOrderCount)
                    $('#leaveManage').html(leaveManageCount)
                }
                //无权限
                if (res.code ==2) {
                    console.log('没有权限')
                    clearInterval(int); //清除定时器
                    setTimeout(getCount,7200000) // 2小时再次请求
                    return false;
                }
                if (res.data.val == 3){
                    //10秒
                    var driverRefuseCount = 0;
                    if (res.data.driverRefuseCount) {
                        driverRefuseCount = res.data.driverRefuseCount
                    }
                    var suspendOrderCount = 0;
                    if (res.data.suspendOrderCount) {
                        suspendOrderCount = res.data.suspendOrderCount
                    }
                    var leaveManageCount = 0;
                    if (res.data.leaveManageCount) {
                        leaveManageCount = res.data.leaveManageCount
                    }
                    $('#driverRefuse').html(driverRefuseCount)
                    $('#suspendOrder').html(suspendOrderCount)
                    $('#leaveManage').html(leaveManageCount)
                    layer.msg(res.msg,{
                        time: 15000,
                        area: ['450px','150px']
                    });
                    // autoPlay();
                    // setTimeout(closePlay,15000);
                } else {
                    return false;
                }
            }
        });
    }

    //开启音乐
    function autoPlay() {
        var myAuto = document.getElementById('myaudio');
        myAuto.play();
    }
    //关闭音乐
    function closePlay() {
        var myAuto = document.getElementById('myaudio');
        myAuto.pause();
        myAuto.load();
    }
</script>
</body>
</html>